package com.mxx.common.websecurity;

import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.security.authentication.AuthenticationDetailsSource;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.security.web.session.SessionInformationExpiredStrategy;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Auther: Mr. Zeng
 * @Date: 2020/7/21 11:24
 * @Description: 暂无描述
 */
@Data
@Accessors(chain = true)
public final class AuthenticationParameter {
    /**
     * 请求中的验证键名称
     */
    private String verificationName;
    /**
     * 持久化存储的 验证键名称
     */
    private String storageName;
    /**
     * 资源名称
     */
    private List<String> resourcePath;
    /**
     * 登录异常处理
     */
    private AuthenticationFailureHandler failureHandler;
    /**
     * session 错误异常
     */
    private AuthenticationFailureHandler sessionFailureHandler;
    /**
     * 登录成功处理
     */

    private AuthenticationSuccessHandler successHandler;
    /**
     * 登录详细信息存储制造源 ，可用于 验证码 、文字选择、拖拽、刮图等处理
     */
    private AuthenticationDetailsSource<HttpServletRequest, ?> authenticationDetailsSource;
    /**
     * 身份信息处理器
     */
    private AuthenticationProvider authenticationProvider;

    /**
     * 登出Url
     */
    private String logoutUrl;
    /**
     * 登出成功 处理器
     */
    private LogoutSuccessHandler logoutSuccessHandler;
    /**
     * 登录页
     */
    private String loginPage;
    /**
     * 开启越域
     */
    private boolean csrf;
    /**
     * 开启frame 访问
     */
    private boolean sameOrigin;
    /**
     * 加解密器
     */
    private PasswordEncoder passwordEncoder;
    /**
     * 用户处理
     */
    private AuthenticationBodyHandler authenticationBodyHandler;

    /**
     * session 会话超时 处理
     */
    private SessionInformationExpiredStrategy sessionInformationExpiredStrategy;

    protected AuthenticationParameter() {
    }

    public String[] getResourcePathArray() {
        return this.resourcePath.toArray(new String[this.resourcePath.size()]);
    }


}
